<template>
    <div class="adr">
        <ul>
           <li v-for="(item, i) in aaa" :key="i">

                <input type="checkbox" name='add' v-model="item.checked" @click="cli(i)">
                <p>
                    <span > {{item.name}}：{{item.phone}}</span>
                    <span>{{item.add}}</span>
                </p>
            </li>
        </ul>
        <div class="btn" @click="yes">确定此地址</div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            aaa:[{
                id:1,
                name:'邓志浩',
                phone:13153310386,
                add:'山东省威海市经济开发区莲花县赤水狗子村',
                checked:false
            },{
                id:2,
                name:'里斯',
                phone:13153315555,
                add:'山东省威海市经济开发区莲花县赤水狗子村',
                checked:true
            },{
                id:3,
                name:'里斯',
                phone:13153315,
                add:'山东省威海市经济开发区莲花县赤水狗子村',
                checked:false
            }],
            addmes:{
                id:1,
                name:'里斯',
                phone:13153315555,
                add:'山东省威海市经济开发区莲花县赤水狗子村',
                checked:false
            }
        }
    },
    methods: {
        // 选中一个时其余的取消选中
        cli(i){
            console.log(i,'cli');
            this.aaa.map((item)=>{
                item.checked = false
            })
            this.addmes = this.aaa[i]
        },
        yes(){

            console.log(this.addmes,'addmes');

            this.$emit('gift',this.addmes)

        }
    },
}
</script>
<style scoped>
.adr{
    width: 7.5rem;
    height: 117rem;
    /* background: #896; */
    z-index: 1;
    position: relative;
}
.adr ul li{
    width:7.5rem ;
    height: 1.5rem;
    background: rgb(248, 247, 250);
    border-radius: 0.5rem;
    font-size: 0.3rem;
    line-height: 0.4rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
}
.adr ul li p{
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.adr .btn{
    width: 80%;
    height: 1rem;
    position:fixed;
    bottom: 0.2rem;
    left: 10.5%;
    border-radius: 0.5rem;
    text-align: center;
    line-height: 1rem;
    background: #ff6040;
}
</style>